﻿/****************************************
 *  copyright (c) 2008 leo shen
 *  
 *  all rights reserved         
 * 
 *  e-mail : syl.lucky@gmail.com
 * *************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace DotUpdater.AppStart
{
    public sealed class Configer
    {
        public static string FileListURL
        {
            get
            {
                return ConfigurationManager.AppSettings["fileListUrl"];
            }
        }

        public static string LocalVersion
        {
            get
            {
                return ConfigurationManager.AppSettings["localVersion"];
            }
        }

        public static string CurrentFilesHttpAddress
        {
            get
            {
                return ConfigurationManager.AppSettings["CurrentFilesHttpAddress"];
            }
        }

        public static string LocalFilesPath
        {
            get
            {
                return ConfigurationManager.AppSettings["LocalFilesPath"];
            }
        }

        public static string MainFile
        {
            get
            {
                return ConfigurationManager.AppSettings["mainFile"];
            }
        }

        public static void SetCurrentVersion(string version)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
            string XPath = "/configuration/appSettings/add[@key='localVersion']";
            doc.SelectSingleNode(XPath).Attributes["value"].Value = version;
            doc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
        }
    }
}
